﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="Fitness.RecipesPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Fitness"
    xmlns:data="using:Fitness.Data"
    xmlns:common="using:Fitness.Common"
    xmlns:tiles="using:Fitness.VariableTemplate"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">


    <Page.TopAppBar>
        <AppBar x:Name="appBar2" Padding="10,0,10,0" Background="#FFD7D7D7" BorderBrush="{x:Null}" MinHeight="88" d:IsHidden="True">
            <Grid Margin="0" >
                <StackPanel Margin="110,10,0,10" Orientation="Horizontal" HorizontalAlignment="Left" Height="90">
                    <Button x:Name="btnTopApp" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0" Style="{StaticResource TopAppStyl}" Height="91" Tapped="btnTopApp_Tapped_1">
                        <Image Width="85" Height="89" Source="Assets/AppTop1.png" Stretch="None" VerticalAlignment="Top"/>
                    </Button>
                    <Button x:Name="btnTopApp2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0" Style="{StaticResource TopAppStyl}" Height="91" Margin="0,0,0,-1">
                        <Image Width="85" Height="89" Source="Assets/AppTop2.png" Stretch="None" VerticalAlignment="Top"/>
                    </Button>
                    <Button x:Name="btnTopApp3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0" Style="{StaticResource TopAppStyl}" Height="91" Margin="0,0,0,-1" Tapped="btnTopApp3_Tapped_1">
                        <Image Width="85" Height="89" Source="Assets/AppTop3.png" Stretch="None" VerticalAlignment="Top"/>
                    </Button>
                    <Button x:Name="btnTopApp4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0" Style="{StaticResource TopAppStyl}" Height="91" Margin="0,0,0,-1">
                        <Image Width="85" Height="89" Source="Assets/AppTop4.png" Stretch="None" VerticalAlignment="Top"/>
                    </Button>
                    <Button x:Name="btnTopApp5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0" Style="{StaticResource TopAppStyl}" Height="91" Margin="0,0,0,-1"  Tapped="btnTopApp5_Tapped_1">
                        <Image Width="85" Height="89" Source="Assets/AppTop5.png" Stretch="None" VerticalAlignment="Top"/>
                    </Button>
                    <Button x:Name="btnTopApp6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0" Style="{StaticResource TopAppStyl}" Height="91" Margin="0,0,0,-1">
                        <Image Width="85" Height="89" Source="Assets/AppTop6.png" Stretch="None" VerticalAlignment="Top"/>
                    </Button>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.TopAppBar>

    <Page.Resources>

        <!--
            Collection of grouped items displayed by this page, bound to a subset
            of the complete item list because items in groups cannot be virtualized
        -->
        <CollectionViewSource
            x:Name="groupedItemsViewSource"
            Source="{Binding Groups}"
            IsSourceGrouped="true"
            ItemsPath="Items"
            d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:RecipesPageDataSource, IsDesignTimeCreatable=True}}"/>

        <tiles:VariableTiles x:Key="MyTemplateSelectorObj" 
                             
                             TipTemplate="{StaticResource TipItemTemplate}"
                             ServiceSmallTemplate="{StaticResource ServiceSmallItemTemplate}"
                             ServiceLargeTemplate="{StaticResource ServiceLargeItemTemplate}"
                             CalculatorsTemplate="{StaticResource CalculatorsItemTemplate}"
                             LatestTemplate="{StaticResource LatestItemTemplate}"
                             RecipesBigTemplate="{StaticResource RecipesBigItemTemplate}"
                             RecipesSmallTemplate="{StaticResource RecipesSmallItemTemplate}"
                             RecipesMediumTemplate="{StaticResource RecipesMediumItemTemplate}"
                             RecipesLagreTemplate="{StaticResource RecipesLagreItemTemplate}"
                             SuccessTemplate="{StaticResource SuccessItemTemplate}">


        </tiles:VariableTiles>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
    	<Grid.Background>
    		<ImageBrush ImageSource="Assets/bg.png"/>
    	</Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Horizontal scrolling grid used in most view states -->
        <!--<GridView
            x:Name="itemGridView"
            AutomationProperties.AutomationId="ItemGridView"
            AutomationProperties.Name="Grouped Items"
            Grid.RowSpan="2"
            Padding="116,137,40,46"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
            ItemTemplate="{StaticResource Standard250x250ItemTemplate}"
            SelectionMode="None"
            IsSwipeEnabled="false">

            <GridView.ItemsPanel>
                <ItemsPanelTemplate>                        
                    <VirtualizingStackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </GridView.ItemsPanel>
            <GridView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="1,0,0,6">
                                <Button
                                    AutomationProperties.Name="Group Title"
                                    Style="{StaticResource TextPrimaryButtonStyle}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
                                        <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
                                    </StackPanel>
                                </Button>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                </GroupStyle>
            </GridView.GroupStyle>
        </GridView>-->
        <tiles:VariableTileControl Grid.Row="1"
        	x:Name="itemGridView"
        	AutomationProperties.AutomationId="ItemGridView"
        	AutomationProperties.Name="Grouped Items"
        	Padding="120,0,40,20"
        	ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
        	ItemTemplateSelector="{StaticResource MyTemplateSelectorObj}"
        	SelectionMode="None"
        	IsItemClickEnabled="True"
        	ItemClick="ItemView_ItemClick" HorizontalContentAlignment="Left" ScrollViewer.HorizontalScrollBarVisibility="Auto">
            <tiles:VariableTileControl.Background>
                <ImageBrush ImageSource="Assets/Bg2.png"/>
            </tiles:VariableTileControl.Background>

            <tiles:VariableTileControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </tiles:VariableTileControl.ItemsPanel>
            <tiles:VariableTileControl.GroupStyle>
                <GroupStyle >
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <StackPanel Margin="1,0,0,6" Orientation="Horizontal">
                                <Button
        							AutomationProperties.Name="Group Title"
        							Content="{Binding Title}"
        							Click="Header_Click"
        							Style="{StaticResource TextButtonStyle}" FontWeight="Light" Foreground="Black" FontSize="26.667" Background="White" BorderBrush="Black"/>
                                <!--<TextBlock x:Name="txtVideo" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="140,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubTl}"/>
                                <TextBlock x:Name="txtPicture" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub2}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="275,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubT2}"/>-->
                            </StackPanel>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <VariableSizedWrapGrid ItemHeight="5" ItemWidth="5" MaximumRowsOrColumns="110" Orientation="Vertical" Margin="0,0,80,0"/>
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                </GroupStyle>
            </tiles:VariableTileControl.GroupStyle>
        </tiles:VariableTileControl>

        <!-- Vertical scrolling list only used when snapped -->
        <ListView
            x:Name="itemListView"
            AutomationProperties.AutomationId="ItemListView"
            AutomationProperties.Name="Grouped Items"
            Grid.Row="1"
            Visibility="Collapsed"
            Margin="0,-10,0,0"
            Padding="10,0,0,60"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
            ItemTemplate="{StaticResource Standard80ItemTemplate}"
            SelectionMode="None"
            IsSwipeEnabled="false"
            IsItemClickEnabled="True"
            ItemClick="ItemView_ItemClick">

            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="7,7,0,0">
                                <!--<Button
                                    AutomationProperties.Name="Group Title"
                                    Style="{StaticResource TextPrimaryButtonStyle}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
                                    </StackPanel>
                                </Button>-->
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListView.GroupStyle>
        </ListView>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}" Text="Recipes" Margin="0,0,300,40"/>
            <Grid x:Name="LogoMain" HorizontalAlignment="Right" Height="89" VerticalAlignment="Center" Width="212" Grid.Column="1" Margin="0,9,40,0">
            	<Grid.Background>
            		<ImageBrush ImageSource="Assets/MainLogo.png"/>
            	</Grid.Background>
            </Grid>
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0">
                            	<DiscreteObjectKeyFrame.Value>
                            		<Thickness>96,0,10,56</Thickness>
                            	</DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list representation is substituted
                    for the grid displayed in all other view states
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LogoMain">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Collapsed</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="pageTitle">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Thickness>0,0,5,40</Thickness>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
